<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js"> </script>
    <script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js"> </script>
</head>
<body>
<input type="button" value="Scan" onclick="AcquireImage();" />
<div id="dwtcontrolContainer" style="float:left; width: 120px;"></div>
<div id="dwtcontrolContainerLargeViewer" style="float:left;"></div>


<script type="text/javascript">
    var DWObject, DWObjectLargeViewer;
    Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', Dynamsoft_OnReady);
    function Dynamsoft_OnReady() {
        DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); // create a thumbnail
        DWObject.IfAllowLocalCache = true;  //打开磁盘缓存
        DWObjectLargeViewer = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainerLargeViewer'); // create a large viewer
        DWObject.RegisterEvent("OnMouseClick", Dynamsoft_OnMouseClick);
    }
    function AcquireImage(){
        if(DWObject) {
            DWObject.Resolution = 200; //属性 扫描200 DPI
            DWObject.SetViewMode(1, 5);
            DWObjectLargeViewer.SetViewMode(1, 1);   // This is actually the default set
            DWObjectLargeViewer.MaxImagesInBuffer = 1; // Set it to hold one image only

            DWObject.AcquireImage();     // Start scanning
        }
    }
    function Dynamsoft_OnMouseClick(index) {
        DWObject.CopyToClipboard(index);  // Copy the image you just clicked on to the clipboard
        DWObjectLargeViewer.LoadDibFromClipboard(); // Load the same image from clipboard into the largeviewer
        DWObject.ShowImageEditor();//图像编辑
    }
</script>
</body>
</html>